package personal.xjl.studentdemo.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import personal.xjl.studentdemo.dao.TeacherMapper;
import personal.xjl.studentdemo.entity.Teacher;
import personal.xjl.studentdemo.service.TeacherService;

import java.util.List;

@Service
public class TeacherServiceImpl implements TeacherService {
    @Autowired
    TeacherMapper teacherMapper;
    @Override
    public boolean login(String username, String password) {
        return !teacherMapper.selectByUsernameAndPassword(username,password).isEmpty();
    }

    @Override
    public int delete(int id) {
        return teacherMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int add(Teacher teacher) {
        return  teacherMapper.insert(teacher);
    }

    @Override
    public Teacher selectById(int id) {
        return teacherMapper.selectById(id);
    }

    @Override
    public void edit(Teacher teacher) {
        teacherMapper.update(teacher);
    }

    @Override
    public List<Teacher> selectByPage(int fromIndex, int pageSize) {
        return teacherMapper.selectByPage(fromIndex,pageSize);
    }
}
